package leetcode100;

public class lc021 {
    public static void main(String[] args) {
        int x = 1;
        int y = 8;
        int res = hammingDistance(x, y);
        System.out.println("res = " + res);
    }

    public static int hammingDistance(int x, int y) {
        int diifX = 0;
        int diffY = 0;
        int oldX = 0;
        int oldY = 0;
        int count = 0;

        for (int i = 0; i < 32; i++) {
            if(x==0&&y==0) break;
            oldX = x;
            oldY = y;
            x = x >> 1;
            y = y >> 1;
            diifX = oldX - x*2;
            diffY = oldY - y*2;
            System.out.println("diifX = " + diifX+ " diffY="+diffY);

            if (diffY != diifX)
                count++;
        }
        return count;

    }
}
